import jieba
from wordcloud import WordCloud
import matplotlib.pyplot as plt

# 假设text是爬取或已有的文本数据
text = "这里是你的文本数据..."

# 中文分词
words = jieba.lcut(text)

# 生成词云
wordcloud = WordCloud(font_path='simhei.ttf',  # 设置字体，确保支持中文
                      width=800, height=400,
                      background_color='white').generate(' '.join(words))

# 显示词云图
plt.figure(figsize=(10, 5))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis('off')  # 不显示坐标轴
plt.show()